/*
 * =========================================================================
 * Copyright 2010 NCS Pte. Ltd. All Rights Reserved This software is
 * confidential and proprietary to NCS Pte. Ltd. You shall use this software
 * only in accordance with the terms of the license agreement you entered into
 * with NCS. No aspect or part or all of this software may be reproduced,
 * modified or disclosed without full and direct written authorisation from NCS.
 * NCS SUPPLIES THIS SOFTWARE ON AN AS IS BASIS. NCS MAKES NO REPRESENTATIONS OR
 * WARRANTIES, EITHER EXPRESSLY OR IMPLIEDLY, ABOUT THE SUITABILITY OR
 * NON-INFRINGEMENT OF THE SOFTWARE. NCS SHALL NOT BE LIABLE FOR ANY LOSSES OR
 * DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
 * THIS SOFTWARE OR ITS DERIVATIVES. Change Revision author/Date version desc
 * -------------------------------------------------------------------------
 * yunfeng/Feb 11, 2010 0.1 initial
 * =========================================================================
 */


import java.io.File;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import canglang.scan.core.base.util.FileUtil;
import canglang.scan.erecord.model.ErecordModel;
import canglang.scan.erecord.service.ErecordManager;

public class JunitTest {
    ClassPathXmlApplicationContext ctx = null;

    protected String[] getConfigLocations () {
        return new String[] { "classpath:applicationContext.xml", "classpath:spring/spring-bean-*.xml" };
    }

    @Before
    public void setUp () throws Exception {
        try {
            System.out.println("call @Before before a test method");
            ctx = new ClassPathXmlApplicationContext(getConfigLocations());
        } catch (RuntimeException e) {
            e.printStackTrace();
        }
    }

    @After
    public void tearDown () throws Exception {
        try {
            System.out.println("call @After after a test method");
        } catch (RuntimeException e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testUser () {
        ErecordManager erecordManager = (ErecordManager) ctx.getBean("erecordManager");
        ErecordModel erecordModel =new ErecordModel();
        erecordModel.setRecordName("3");
        erecordModel.setRecordType("31");
        erecordModel.setUploadContent(null);
        //erecordModel.setUploadContent(FileUtil.convertToByte(new File("c:\\a.txt")));
        erecordManager.addErecord(erecordModel);
        System.out.println("return result is============ :");
    }
}
